package xhwl.retrofitrx;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;


public class LoadingDialogV2 extends Dialog {
	private Context mContext;

	AnimationDrawable animationDrawable;
	ImageView ivLoading;
	public LoadingDialogV2(Context context) {
		super(context, R.style.loadingDialogV3);
		mContext=context;
//		setCancelable(false);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		LayoutInflater inflater = LayoutInflater.from(mContext);
		View view = inflater.inflate(R.layout.dialog_loading_v2, null);
		setContentView(view);
		ivLoading= (ImageView) this.findViewById(R.id.ivLoading);
		ivLoading.setBackgroundResource(R.drawable.loading_w);
		animationDrawable=(AnimationDrawable)ivLoading.getBackground();
//		ivLoading.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_w));
//		animationDrawable = (AnimationDrawable)ivLoading.getDrawable();


	}

	@Override
	public void show() {
		super.show();
		animationDrawable.start();
	}

	@Override
	public void dismiss() {
		super.dismiss();
		animationDrawable.stop();
	}
}
